# -*-coding = utf-8 -*-

# @Time: 2021/4/4 21:31
# @Author: bistro
# @File: p26.py
# @Software: PyCharm
from typing import List


class Solution:
    """
    双指针i 慢指针 ,j 快指针
    """
    def removeDuplicates(self, nums: List[int]) -> int:
        n = len(nums)
        if n == 0:
            return 0
        i = 0
        for num in nums:
            if i < 1 or num != nums[i-1]:
                nums[i] = num
                i += 1
        return i


"""
测试用例
s = Solution()
print(s.removeDuplicates([0, 0, 1, 1, 1, 2, 2, 3, 3, 4]))
"""


def removeDuplicates(nums: List[int]) -> int:
    nums.sort()
    count = 0
    if not nums:
        return count
    if nums.count(nums[0]) != len(nums):
        for i in range(len(nums) - 1, -1, -1):
            if nums[i] != nums[i - 1]:
                count += 1
            else:
                nums.remove(nums[i])
        return count
    else:
        return 1